home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / awe2-0_1.lha / awe2-0.1 / Src / RCS / SpinBarrier.cc,v < prev    next >
Text File  |  1989-02-22  |  3KB  |  220 lines

  1. head     3.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    grunwald:3.2; strict;
  6. comment  @@;
  7.  
  8.  
  9. 3.2
  10. date     89.02.20.15.37.31;  author grunwald;  state Exp;
  11. branches ;
  12. next     3.1;
  13.  
  14. 3.1
  15. date     88.12.20.13.49.17;  author grunwald;  state Exp;
  16. branches ;
  17. next     1.4;
  18.  
  19. 1.4
  20. date     88.10.30.13.04.38;  author grunwald;  state Exp;
  21. branches ;
  22. next     1.3;
  23.  
  24. 1.3
  25. date     88.09.28.22.13.21;  author grunwald;  state Exp;
  26. branches ;
  27. next     1.2;
  28.  
  29. 1.2
  30. date     88.09.21.20.51.29;  author grunwald;  state Exp;
  31. branches ;
  32. next     1.1;
  33.  
  34. 1.1
  35. date     88.09.18.16.42.23;  author grunwald;  state Exp;
  36. branches ;
  37. next     ;
  38.  
  39.  
  40. desc
  41. @@
  42.  
  43.  
  44. 3.2
  45. log
  46. @Start using Gnu library heaps for schedulers
  47. @
  48. text
  49. @// This may look like C code, but it is really -*- C++ -*-
  50. // 
  51. // Copyright (C) 1988 University of Illinois, Urbana, Illinois
  52. //
  53. // written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
  54. //
  55. #include "SpinBarrier.h"
  56. #include "Pragma.h"
  57.  
  58. PRAGMA_LINKAGE_C
  59. extern int getpid();
  60. PRAGMA_LINKAGE
  61.  
  62. extern void makeVolatile( void * );
  63.  
  64. //
  65. //    Make everyone exit
  66. //
  67. void
  68. SpinBarrier::lowerBarrier()
  69. {
  70.     reserve();
  71.     generation++;
  72.     pCount = 0;
  73.     release();
  74. }
  75.  
  76. int
  77. SpinBarrier::rendezvous()
  78. {
  79.     reserve();
  80.     pCount++;
  81.  
  82.     //
  83.     // Waiting people just read generation, and the final process
  84.     // just writes it, so we don't really even need to use the locks here.
  85.     //
  86.     if ( pCount == pHeight ) {
  87.     pCount = 0;
  88.     generation++;
  89.     release();
  90.     } else {
  91.     int gen = generation;
  92.     release();
  93.     int timesAround = 0;
  94.     int totalGetPids = 0;
  95.     while ( gen == generation ) {
  96.         if ( timesAround > pLoops ) {
  97.         (void) getpid();
  98.         timesAround = 0;
  99.         totalGetPids++;
  100.         if ( pMaxLoops > 0 && totalGetPids > pMaxLoops ) {
  101.             return(0);
  102.         }
  103.         }
  104.         timesAround++;
  105.         makeVolatile(&gen);
  106.     }
  107.     }
  108.     return(1);
  109. }
  110.  
  111. void
  112. SpinBarrier::height(int newHeight)
  113. {
  114.     reserve();
  115.     if (pCount >= newHeight) {
  116.     pCount = 0;
  117.     generation++;
  118.     }
  119.     else {
  120.     pHeight = newHeight;
  121.     }
  122.     release();
  123. }
  124. @
  125.  
  126.  
  127. 3.1
  128. log
  129. @Steay version
  130. @
  131. text
  132. @@
  133.  
  134.  
  135. 1.4
  136. log
  137. @*** empty log message ***
  138. @
  139. text
  140. @d8 1
  141. d10 1
  142. d12 1
  143. d14 5
  144. d20 1
  145. a20 1
  146. SpinBarrier::rendezvous()
  147. a21 2
  148.     int timesAround = 0;
  149.  
  150. d23 2
  151. a24 2
  152.     int gen = generation;
  153.     count++;
  154. d26 1
  155. d28 6
  156. d38 4
  157. a41 3
  158.     if ( count == pHeight ) {
  159.     count = 0;
  160.     generation = gen + 1;
  161. d43 4
  162. d51 4
  163. d57 1
  164. d60 15
  165. @
  166.  
  167.  
  168. 1.3
  169. log
  170. @*** empty log message ***
  171. @
  172. text
  173. @d1 7
  174. a7 1
  175. #include "HardBarrier.h"
  176. d12 1
  177. a12 1
  178. HardBarrier::rendezvous()
  179. @
  180.  
  181.  
  182. 1.2
  183. log
  184. @*** empty log message ***
  185. @
  186. text
  187. @a4 2
  188. const int MaxTimesAround = 1000;
  189.  
  190. d10 1
  191. a10 1
  192.     lock.reserve();
  193. d13 1
  194. a13 1
  195.     lock.release();
  196. d24 1
  197. a24 1
  198.         if (timesAround > MaxTimesAround) {
  199. @
  200.  
  201.  
  202. 1.1
  203. log
  204. @Initial revision
  205. @
  206. text
  207. @d5 2
  208. d10 2
  209. d15 6
  210. d23 9
  211. a31 5
  212.     generation++;
  213.     } else while ( gen == generation ) {
  214.     lock.release();
  215.     (void) getpid();
  216.     lock.reserve();
  217. a32 1
  218.     lock.release();
  219. @
  220.